﻿# -*- coding:utf-8 -*-
#
# ГИМ
#
from django.db import models
from django.contrib.auth.models import User


class CatDepartment(models.Model):
    name = models.CharField(max_length=64, verbose_name="Наименование")



class Phone(models.Model):
    number = models.CharField(max_length=64, verbose_name="Номер")
    type = models.CharField(max_length=16, blank=True, verbose_name="Тип")
    room = models.CharField(max_length=8, blank=True, verbose_name="Комната")
    
    class Meta:
        ordering = ['number']

    def __unicode__(self):
        return self.number 


class Department(models.Model):
    parent = models.ForeignKey("self", blank=True, null=True, verbose_name="Головной отдел")
    level = models.IntegerField(blank=True, default=1, verbose_name="уровень")
    name = models.CharField(max_length=64, verbose_name="Наименование")
    room = models.CharField(max_length=8, blank=True, verbose_name="Комната")
    phone = models.ManyToManyField(Phone, blank=True, null=True, verbose_name="Телефон")

    class Meta:
        ordering = ['-level', 'name']

    def __unicode__(self):
        return u'%s' % self.name


class Employee (models.Model):
    department = models.ForeignKey(Department)
    name1 = models.CharField(max_length=64, verbose_name="Фамилия")
    name2 = models.CharField(max_length=64, blank=True, verbose_name="Имя")
    name3 = models.CharField(max_length=64, blank=True, verbose_name="Отчество")
    post = models.CharField(max_length=64, blank=True, verbose_name="Должность")
    ktit_staff = models.BooleanField(verbose_name="Сотрудник КТиТ")
    boss = models.BooleanField(verbose_name="Руководитель")
    phone = models.ManyToManyField(Phone, blank=True, null=True, verbose_name="Телефон")

    class Meta:
        ordering = ['name1']

    def __unicode__(self):
        return self.name1 

		

